package com.situ.feemanagement.controller;

import com.situ.feemanagement.pojo.Restocking;
import com.situ.feemanagement.pojo.query.RestockingQuery;
import com.situ.feemanagement.pojo.vo.RestockingVO;
import com.situ.feemanagement.service.IRestockingService;
import com.situ.feemanagement.util.PageResult;
import com.situ.feemanagement.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/restocking")
public class RestockingController {

    @Autowired
    private IRestockingService restockingService;

    @RequestMapping("/selectByPage")
    public PageResult<RestockingVO> selectByPage(RestockingQuery restockingQuery) {
        return restockingService.selectByPage(restockingQuery);
    }

    @RequestMapping("/deleteById")
    public Result deleteById(String id) {
        restockingService.deleteById(Integer.parseInt(id));
        return Result.ok("删除成功");
    }

    @RequestMapping("/deleteAll")
    public Result deleteAll(String[] ids) {
        restockingService.deleteAll(ids);
        return Result.ok("删除成功");
    }

    @RequestMapping("/add")
    public Result add(Restocking restocking) {
        restockingService.add(restocking);
        return Result.ok("添加成功");
    }

    @RequestMapping("/selectById")
    public Result selectById(String id) {
        Restocking restocking = restockingService.selectById(Integer.parseInt(id));
        return Result.ok(restocking);
    }

    @RequestMapping("/update")
    public Result update(Restocking restocking) {
        restockingService.update(restocking);
        return Result.ok("更新成功");
    }
}
